<?php
namespace app\admin\controller;

use app\common\model\LogAdmin as LogAdminModel;

class Logadmin extends Base
{
    /**
     * [getIndex  操作日志列表]
     * @param
     * @return mixed|\think\response\Json
     * @author [C。]
     */
    public function index()
    {
        $param = input('param.');
        $map = [];
        $this->getPageAndSize($param);
        $model = new LogAdminModel;
        try{
            $map['status'] = 1;
            $count = $model->getCount($map);//满足条件的总数
            $allpage = intval(ceil($count / $this->size));//总页数
            $lists = $model->getList($map, $this->from, $this->size,'admin_name,description,ip,create_time');
            foreach($lists as &$v){
                $addtime = $v['create_time'];
                $v['addtime'] = get_last_time(strtotime($addtime));
            }
        }catch (\Exception $e) {
            return admin_json(-1,$e->getMessage());
        }
        return admin_json(1, '获取成功',[
            'count' => $count,//总记录数
            'allpage' => $allpage,  //总页数
            'lists' => $lists,  //列表数据
        ]);
    }
}